package jdk8;

import java.lang.Runnable;
import java.util.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class Lambda2 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("老虎");
        list.add("tiger");
        list.add("cat");
        list.add("小猫");
        list.add("pig");
        System.out.println("lambda实现String 按照长度比较");
        list.sort((o1,o2)->{
          return o1.length()-o2.length();
        });
        System.out.println(list);
        list.sort((o1,o2)->{
            return o2.length()-o1.length();
        });
        System.out.println(list);
        list.sort((o1,o2)->{
            return o1.compareTo(o2);
        });
        System.out.println(list);

//        list.sort(new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return 0;
//            }
//        });

        Thread th=new Thread(()->{
            for (int i = 0; i < 20; i++) {
                System.out.println(Thread.currentThread().getName()+" "+i);
            }
        });
        th.start();
    }
}
